<?php

namespace App\Filter;

use EloquentFilter\ModelFilter;

class ReportWorkFilter extends ModelFilter
{
    /**
    * Related Models that have ModelFilters as well as the method on the ModelFilter
    * As [relationMethod => [input_key1, input_key2]].
    *
    * @var array
    */
    public $relations = [];

    public function search(string $value)
    {
        return $this->where(function($query) use ($value) {
            return $query->where('project_name','like','%'.$value.'%')
                ->orWhere('title','like','%'.$value.'%');
        });
    }

    public function date($value)
    {
        return $this->where(function ($query) use ($value){
            return $query->whereDate('report_date',$value);
        });
    }
}
